/**************************************************************************
 * @doc CITI
 * @module CITISrc |
 * Source code for the CITI handling functions.
 *
 * Product         :   SoftPay 2000 (Global Payment Methodology).
 * <nl>Developer   :   SoftPay Development Team ASPAC ADC.
 * <nl>Notes       :
 *
 * @head3 CITI Functions |
 * @index | CITI
 * @end
 *
 * Copyright (c) 1996-2005 by VeriFone Inc. All rights reserved.
 *
 * No part of this software may be used, stored, compiled, reproduced,
 * modified, transcribed, translated, transmitted, or transferred, in any form
 * or by any means whether electronic, mechanical, magnetic, optical,
 * or otherwise, without the express prior written permission of VeriFone, Inc.
 *
 * Revision History
 * ------------------------------------------------------------------------
 *
 *
 ********************************************************************************/

int inCITICreateVariantStruct63(void);
void vdAddCITIFunctions(void);

int inSetCITITransFields(TRANSACTION_OBJECT* pobTran,int host,unsigned int inTransCode,char* szProcCode);
void vdInitializeCITI( PACKET_OBJECT *pobPacket );
int inSendReceiveCITI(PROTOCOL_OBJECT* pobProtocol,PACKET_OBJECT* pobPacket);
int inImamReferralSendReceive(PROTOCOL_OBJECT* pobProtocol,PACKET_OBJECT* pobPacket);
void vdLoadCITIEMVField23(TRANSACTION_OBJECT* pobTran);
int inCITIBuildEMVHostData23(TRANSACTION_OBJECT *pobTran,unsigned char *pbtBuff, unsigned short *pusLen);
int inCITIAddDataToEMVPacket23(unsigned short usTag, unsigned char *pbtPackBuff);
void vdCITILoadField35(TRANSACTION_OBJECT* pobTran);
void vdLoadCITIField48(TRANSACTION_OBJECT *pobTran);
void vdLoadCITIField54(TRANSACTION_OBJECT* pobTran);
int inCITIInit(PACKET_OBJECT* pobPacket);
int inCITIPIPAnalyse(PACKET_OBJECT* pobPacket);
void vdLoadCITIField63 (TRANSACTION_OBJECT *pobTran);
int inCITISettleAHost(TRANSACTION_OBJECT* pobTran);
int inCITISaveSummaryReport (TRANSACTION_OBJECT *pobTran);
int inCITISaveSummaryMiddle (TRANSACTION_OBJECT *pobTran, int *pinReportTop, int inNumberOfMerchants);
int inCITISummaryReportOperation (TRANSACTION_OBJECT *pobTran);
int inCITIPrintSummaryReport (PRINTER_OBJECT *pobPrinter, TRANSACTION_OBJECT *pobTran);
int inCITIPrintSummaryMiddle(PRINTER_OBJECT* pobPrinter,TRANSACTION_OBJECT* pobTran,int* pinReportTop,int inNumberOfMerchants);
int inImamPrintSummaryMiddle(PRINTER_OBJECT* pobPrinter,TRANSACTION_OBJECT* pobTran,int* pinReportTop,int inNumberOfMerchants);
	
int inCheckAllowed(TRANSACTION_OBJECT *pobTran);
int inCitiValidateTransaction(TRANSACTION_OBJECT * pobTran);
int enableinvoice(TRANSACTION_OBJECT * pobTran);
int enableinvoiceepp(TRANSACTION_OBJECT * pobTran);
int enableinvoicecash(TRANSACTION_OBJECT * pobTran);
int enableinvoicecabk(TRANSACTION_OBJECT * pobTran);
int enableinvoiceAMEX(TRANSACTION_OBJECT * pobTran);
int enableinvoiceJCB(TRANSACTION_OBJECT * pobTran);
int enableinvoiceDINERS(TRANSACTION_OBJECT * pobTran);
int inCITIReprintFileCopy(TRANSACTION_OBJECT *pobTran);
int inSetCITIVoidOnline(TRANSACTION_OBJECT *pobTran);
 int inEndEPPComm(TRANSACTION_OBJECT * pobTran);
 int inSelectRegularPromo(TRANSACTION_OBJECT * pobTran);
 int inGetCITIEPPTenor(TRANSACTION_OBJECT *pobTran);
 int inValEPPTenor(char *pszBuf);
 int inGetEPPCashBackAmount(TRANSACTION_OBJECT * pobTran);
 int inGetEPPCashAmount(TRANSACTION_OBJECT * pobTran);
 int inGetInvoiceNumber1 (TRANSACTION_OBJECT *pobTran);
 int inCheckHost(TRANSACTION_OBJECT *pobTran);
int inBOPSettleAllHosts(TRANSACTION_OBJECT *pobTran);
int inCITIEditSIGOperation (TRANSACTION_OBJECT *pobTran);
int inCITIEditETTOperation (TRANSACTION_OBJECT *pobTran);
int inSelectSaleEpp(TRANSACTION_OBJECT *pobTran);
int inEnterCardData1 (TRANSACTION_OBJECT *pobTran);
int inEnterCardData2 (TRANSACTION_OBJECT *pobTran);
int inEnterCardData3 (TRANSACTION_OBJECT *pobTran);
int inGetCardBin1 (TRANSACTION_OBJECT *pobTran,char *pchCardNum,unsigned fManual);
int inGetCardBin2 (TRANSACTION_OBJECT *pobTran,char *pchCardNum,unsigned fManual);
int inGetCardBin3 (TRANSACTION_OBJECT *pobTran,char *pchCardNum,unsigned fManual);
int inCPACValidateSwipedCard1 (TRANSACTION_OBJECT *pobTran);
int inCPACValidateSwipedCard2 (TRANSACTION_OBJECT *pobTran);
int inCPACValidateSwipedCard3 (TRANSACTION_OBJECT *pobTran);
int inLoadGetCDTIndex1 (TRANSACTION_OBJECT *pobTran, char *pchPan);
int inLoadGetCDTIndex2 (TRANSACTION_OBJECT *pobTran, char *pchPan);
int inLoadGetCDTIndex3 (TRANSACTION_OBJECT *pobTran, char *pchPan);
int inValidateManualCardNo1 (TRANSACTION_OBJECT *pobTran,char *pchAcctNum);
int inValidateManualCardNo2 (TRANSACTION_OBJECT *pobTran,char *pchAcctNum);
int inValidateManualCardNo3 (TRANSACTION_OBJECT *pobTran,char *pchAcctNum);
int inCITISelectAndLoadHost(TRANSACTION_OBJECT *pobTran);
int inCITIDisplayAtIdle(TRANSACTION_OBJECT* pobTran) ;
int inCITIStartCardTxn (TRANSACTION_OBJECT *pobTran);
int inCITIPrintReceiptTop(TRANSACTION_OBJECT* pobTran);
int inCITIPrintReceiptBottom (TRANSACTION_OBJECT *pobTran);
int inCITIPrintReceiptBottomLines(PRINTER_OBJECT *obPrinter, TRANSACTION_OBJECT *pobTran);
int inCITIEPPReceiptBottomLines(PRINTER_OBJECT *obPrinter, TRANSACTION_OBJECT *pobTran);
int inCITIEPPCASHBACKReceiptBottomLines(PRINTER_OBJECT *obPrinter, TRANSACTION_OBJECT *pobTran);
int inCITIEPPCASHReceiptBottomLines(PRINTER_OBJECT *obPrinter, TRANSACTION_OBJECT *pobTran);
int inEPPMonthCalculation(TRANSACTION_OBJECT *pobTran);
int inCITIPrinterCheck(TRANSACTION_OBJECT *pobTran);
int inCITIChkPrinterStatus(PRINTER_OBJECT* pobPrinter);
int inCITIGetInvoiceNumber (TRANSACTION_OBJECT *pobTran);
int inCITIGetInvNum(TRANSACTION_OBJECT* pobTran);
int inCITIRePrintSettleReport(PRINTER_OBJECT* pobPrinter,TRANSACTION_OBJECT* pobTran);
int inCITIallReprintSettleReport(TRANSACTION_OBJECT* pobTran);
int inCITIUpdateOfflineAccum(TRANSACTION_OBJECT* pobTran,ACCUM_VALUES* psrAccum);
int inCITICustComputeAndDispTotal(TRANSACTION_OBJECT* pobTran);
void vdCITIMakeReceiptTop (TRANSACTION_OBJECT *pobTran);
int inCITIValidateVoid(TRANSACTION_OBJECT* pobTran);
int inCITIEndModem(TRANSACTION_OBJECT *pobTran);
void vdFormatPANDisplay(TRANSACTION_OBJECT* pobTran,char* pchPAN,char* pchFmtPAN,int inFmtPANSize);
int inCITICustDisplaySwipeCardInfo(TRANSACTION_OBJECT* pobTran);
int inCITIReprintSettleRep(TRANSACTION_OBJECT *pobTran);
int inSettlementFlagTrue(TRANSACTION_OBJECT *pobTran);
int inSettlementFlagFalse(TRANSACTION_OBJECT *pobTran);
void citi_hex_2_asc(char *poutMessage, unsigned char *pucMessage, int inLen);
int inChangeSaleCompMsgforVoid(TRANSACTION_OBJECT *pobTran);
int inCITIBankReferral(TRANSACTION_OBJECT *pobTran);
int inCITIDisplayAppLabel(TRANSACTION_OBJECT *pobTran);
int inCITIEditCOMOperation(TRANSACTION_OBJECT *pobTran);

extern int inCPACInit(PACKET_OBJECT* pobPacket);
extern int inCPACPIPAnalyse  (PACKET_OBJECT *pobPacket);
extern int inCPACPIPDeinitialize(PACKET_OBJECT* pobPacket);
extern int inCPACEnterWithMessage(long lnMessageNumber,VS_BOOL fScrollDisplay,int inPromptRow,int inEntryRow,char* szResponseString,int inDataType,int inMaxChars,int  (*inValidator) (char* szResponseString)) ;
extern int inConfRecEdit(const char* pchDataFileName);
extern int get_battery_status(void);
extern int inCASHSelectAndLoadHost (TRANSACTION_OBJECT *pobTran);
extern int inCABKSelectAndLoadHost (TRANSACTION_OBJECT *pobTran);
extern void vdSetPrintReceiptConditions(TRANSACTION_OBJECT* pobTran);
extern void vdMakeReceiptTop (TRANSACTION_OBJECT *pobTran);
extern void vdCPACMakeReceiptAfterResp (TRANSACTION_OBJECT *pobTran);
extern int inPrintReceiptHeader2(PRINTER_OBJECT* obPrinter,TRANSACTION_OBJECT* pobTran);
extern void vdGetCPACRetRefNum(BATCH_REC* psrBRec,unsigned char* pszData);
extern void vdGetCPACUserInvNum(BATCH_REC* psrBRec,unsigned char* pszData);
extern int inCPACPrintReceiptMiddle(PRINTER_OBJECT* obPrinter) ;
extern void vdSetReceiptFooterConditions(TRANSACTION_OBJECT* pobTran);
extern int inPrintReceiptFooterLines(PRINTER_OBJECT* obPrinter) ;
extern int inCPACBaseRespValidation (VALIDATION_STRUCT *psrRespValStruct, int  inInternalVal);
extern void vdGetReversalFileName(char* pszFName,int inHostIndex);
extern void ACTIVITY_LOG(const char* pszLogMessage); 
extern void vdSetCPACOpenTabOffline(BATCH_REC* psrBRec,VS_BOOL fData);
extern int inResetDemoBatch(TRANSACTION_OBJECT* pobTran);
extern int inResetBatch(TRANSACTION_OBJECT* pobTran);
extern int inSelectOneAllMID(TRANSACTION_OBJECT* pobTran,VS_BOOL fPromptMerchFlag);
extern int inDBFileExists(const char* pszFileName);
extern int inDBRemoveFile(const char* pszFileName);
extern int inDBCreateFile(const char* pszFileName,unsigned int uiRecordSize);
extern int inDBWriteRecord(const char* pszFileName,int inRecNum,const unsigned char* pucBuf);
extern int inDBReadRecord(const char* pszFileName,unsigned int uiRecNum,unsigned char* pucBuf);
extern int inDBTotalRecords(const char* pszFileName);
extern void vdComputeTransactionTotal(char* szAmt,TRANSACTION_OBJECT* pobTran);
extern VS_BOOL fGetCheckFloorLimit(TRANSACTION_OBJECT* pobTran);
extern VS_BOOL fAmountLessThanFloorLimit(TRANSACTION_OBJECT* pobTran);
extern void vdMakeFooter(TRANSACTION_OBJECT* pobTran);
extern void vdCustScroll(void);
extern void vdCustDispTotAmount(char* pszAmount);
extern char chGetCPACAdjTipAdjflag(BATCH_REC* psrBRec,unsigned char* pszData);
extern void vdEMVMakeReceiptAfterResp(TRANSACTION_OBJECT *pobTran);
extern void hex_2_asc(BYTE *outp, BYTE *inp, int length);
extern void vdSetEMVOnlineCondition(TRANSACTION_OBJECT *pobTran, int inPipResult);
extern int inEMVReferralProcessing(TRANSACTION_OBJECT *pobTran);

int inCITIEditPABXOper(TRANSACTION_OBJECT *pobTran);
int inCITIPrintConfigOper(TRANSACTION_OBJECT *pobTran);
int inCITIPrintText(char *szDataPrint, int inMode);
int inImamReversalSendReceive(TRANSACTION_OBJECT* pobTran,int inISOSendSize);

extern int inImamReferralSendReceive(PROTOCOL_OBJECT* pobProtocol,PACKET_OBJECT* pobPacket) ;

extern void vdSetCPACRetRefNum(BATCH_REC* psrBRec,unsigned char* pszData);

#ifdef IMAM_BNI
int inImamGetTag(unsigned char *szTag, int *inTagLen, unsigned char *szHexBuff, unsigned char *szValue);

#endif
//KiaSoon - 23122005: Added for PRINT CONFIG
#define PRINT_NORMAL 		0
#define PRINT_DBL_HEIGHT 	1
#define PRINT_DBL_WIDTH 	2
#define PRINT_DBL_HEIGHT_WIDTH  3

